<template>
  <div class="xtx-pay-page">
    <div class="container">
      <XtxBread>
        <XtxBreadItem to="/">首页</XtxBreadItem>
        <XtxBreadItem to="/cart">购物车</XtxBreadItem>
        <XtxBreadItem>支付结果</XtxBreadItem>
      </XtxBread>
      <!-- 支付结果 -->
      <!-- 订单状态，1为待付款、2为待发货、3为待收货、4为待评价、5为已完成、6为已取消 -->
      <!-- 1446081547370237954 -->
      <!-- 已经付款  1446081747342069762 -->
      <div class="pay-result" v-if="orderDetail">
        <template v-if="orderDetail.orderState === 1">
          <span class="iconfont icon-shanchu red"></span>
          <p class="tit">该订单还没付款</p>
          <XtxButton
            type="primary"
            @click="$router.push(`/pay?id=${orderDetail.id}`)"
            >去付款</XtxButton
          >
        </template>
        <template v-if="orderDetail.orderState === 2">
          <span class="iconfont icon-queren2 green"></span>
          <p class="tit">订单支付成功</p>
          <p class="tip">我们将尽快为您发货，收货期间请保持手机畅通</p>
        </template>
        <p v-if="orderDetail.payChannel === 2">
          支付方式：<span>微信支付</span>
        </p>
        <p v-else-if="orderDetail.payChannel === 1">
          支付方式：<span>支付宝支付</span>
        </p>
        <p>
          支付金额：<span>¥{{ orderDetail.payMoney }}</span>
        </p>
        <div class="btn">
          <XtxButton type="primary" style="margin-right: 20px"
            >查看订单</XtxButton
          >
          <XtxButton type="gray" @click="$router.push('/')">进入首页</XtxButton>
        </div>
        <p class="alert">
          <span class="iconfont icon-tip"></span>
          温馨提示：小兔鲜儿不会以订单异常、系统升级为由要求您点击任何网址链接进行退款操作，保护资产、谨慎操作。
        </p>
      </div>
    </div>
  </div>
</template>
<script>
import { reqFindOrderDetail } from '@/api/order'
import { useRoute } from 'vue-router'
import { ref } from 'vue'
export default {
  name: 'XtxPayResultPage',
  setup () {
    const route = useRoute()
    // 保存订单详情变量
    const orderDetail = ref(null)
    // console.log(route.query.orderId)
    // 获取订单详细
    reqFindOrderDetail(route.query.orderId).then(({ result }) => {
      console.log('获取订单详细', result)
      orderDetail.value = result
    })
    return { orderDetail }
  }
}
</script>
<style scoped lang="less">
.pay-result {
  padding: 100px 0;
  background: #fff;
  text-align: center;
  > .iconfont {
    font-size: 100px;
  }
  .green {
    color: #1dc779;
  }
  .red {
    color: @priceColor;
  }
  .tit {
    font-size: 24px;
  }
  .tip {
    color: #999;
  }
  p {
    line-height: 40px;
    font-size: 16px;
  }
  .btn {
    margin-top: 50px;
  }
  .alert {
    font-size: 12px;
    color: #999;
    margin-top: 50px;
  }
}
</style>
